﻿/**
 * ...
 * @author aboutwhat
 */

package bloom.lang;

class Functional 

{

    public static function not <T>(a : T->Bool)
    {
        return function (c) return !a(c);
    }
    
    public static function and <T>(a : T->Bool, b : T->Bool)
    {
        return function (c) return a(c) && b(c);
    }
    
    public static function or <T>(a : T->Bool, b : T->Bool)
    {
        return function (c) return a(c) || b(c);
    }
    
    public static function xor <T>(a : T->Bool, b : T->Bool)
    {
        return function (c) {
            var resA = a(c);
            var resB = b(c);
            return ( resA && !resB ) || ( !resA && resB );
        }
    }
    
}